function initLoadImage() {
    var size = 240;
    $.each($('#gallery').find('img'), function() {
        var o_w = this.offsetWidth;
        var o_h = this.offsetHeight;
        var f_w = 240;
        var f_h = 240;

        if ((o_w > f_w) || (o_h > f_h)) {

            if ((f_w / f_h) > (o_w / o_h))
                f_w = parseInt((o_w * f_h) / o_h);
            else if ((f_w / f_h) < (o_w / o_h))
                f_h = parseInt((o_h * f_w) / o_w);
            this.style.width = f_w + "px";
            this.style.height = f_h + "px";
        } else {
            f_w = o_w;
            f_h = o_h;
        }
        this.style.marginLeft = parseInt((size - f_w) / 2) + 'px';
        this.style.marginTop = parseInt((size - f_h) / 2) + 'px';
    });
}